import { createRouter, createWebHistory } from 'vue-router';
import LoginView from '@/views/login/LoginView.vue';
import Home from '@/views/home/index.vue';
import Register from '@/views/register/index.vue';
import E404 from '@/views/error/E404.vue';
import Device from '@/views/device/index.vue';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: LoginView
    },
    {
      path: '/register',
      name: 'register',
      component: Register
    },
    { path: '/:pathMatch(.*)*', 
      name: 'NotFound', 
      component: E404 
    },
    
    {
      path: '/',
      name: 'index',
      redirect: '/home',
      component: () => import('../layout/Layout.vue'),
      children:[
        {
          path: '/home',
          name: 'home',
          component: Home,
          meta:{
            title:"工作台"
          }
        },
        {
          path: '/device',
          name: 'device',
          component: Device,
          meta:{
            title:"设备管理"
          }
        },
        {
          path: '/project',
          name: 'project',
          component: () => import('@/views/project/index.vue'),
          meta:{
            title:"项目管理"
          }
        },
        {
          path: '/product',
          name: 'product',
          component: () => import('@/views/product/index.vue'),
          meta:{
            title:"产品管理"
          }
        },
        {
          path: '/product/:id/detail/:type',
          name: 'product_detail',
          component: () => import('@/views/product/Detail.vue'),
          props:true,
          meta:{
            title:"产品配置"
          }
        },
      ]
    }
  ]
})

export default router
